<?php
/**
 * 单店自主-项目活动-项目定额
 * @author jianhui
 *
 */
class commonPFixedModel extends MY_Model{
    function commonPFixedModel(){
        parent::MY_Model();
        $this->table = 'CommonPFixed';
    }
    /**
     * 包装数据
     * {@inheritDoc}
     * @see MY_Model::packing()
     */
    function packing($list = array()){
        foreach ($list as $k => $v){
            $v['moneyData'] = unserialize($v['moneyData']);
            $list[$k] = $v;
        }
        return $list;
    }
    /**
     * 获取制定条件的制定项目额度
     * @param integer $storeId 店铺ID
     * @param integer $year 年份
     * @param integer $eventType 项目类型
     * @return number
     */
    function getMoney($storeId, $year, $eventType){
        $this->CI->load->model('sellpointModel');
        $storeData = $this->CI->sellpointModel->getStoreIdData($storeId);
        $findData = $this->getNewData(array('year'=>$year,'systemCity'=>array('like',$storeData['city'])));
        if ($findData && isset($findData['moneyData']['money'.$eventType])){
            return (float)$findData['moneyData']['money'.$eventType];
        }else{
            return 0;
        }
    }
}